package view;

import lombok.SneakyThrows;

import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;

public class SelectFrame extends JFrame {
    public SelectFrame(){
        this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        this.setLayout(new FlowLayout(FlowLayout.CENTER,5,30));
        this.setTitle("功能选择");
        this.setBounds(500,250,350,200);
        JButton crawJButton = new JButton("爬取数据");
        Dimension buttonDim = new Dimension(150,100);
        crawJButton.setPreferredSize(buttonDim);
        JButton viewJButton = new JButton("查看数据");
        viewJButton.setPreferredSize(buttonDim);
        this.add(new JPanel().add(crawJButton));
        this.add(new JPanel().add(viewJButton));
        this.setVisible(true);
        crawJButton.addActionListener(new AbstractAction() {
            @SneakyThrows
            @Override
            public void actionPerformed(ActionEvent e) {
                new ReadJobFrame().setVisible(true);
            }
        });
        viewJButton.addActionListener(new AbstractAction() {
            @SneakyThrows
            @Override
            public void actionPerformed(ActionEvent e) {
                new ManageJobFrame().setVisible(true);
            }
        });
    }
}
